<%@ page contentType="text/html;charset=UTF-8" language="java"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" >
    <title>首页</title>
    <link rel="stylesheet" type="text/css"  href="${pageContext.request.contextPath}/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="themes/icon.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery.easyui.min.js"></script>
    <script>
        $(function () {
            //发送异步请求查询公告
            $.post("IndexServlet",{method:'findNotice'},function (data) {
                var lis = '';
                for (var i = 0; i <data.length ; i++) {
                    lis += '<div class="col-md-6">\n' +
                        '                <div style="background-color: grey;" class="service-desc">\n' +
                        '                    <h3>'+data[i].name+'</h3>\n' +
                        '                    <p>'+data[i].content+'</p>\n' +
                        '                </div>\n' +
                        '            </div>';
                }
                $("#notice").html(lis);
            });
            //发送异步请求查询活动
            $.post("IndexServlet",{method:'findActivity'},function (data) {
                var lis = '';
                for (var i = 0; i <data.length ; i++) {
                    lis += '<div class="col-md-4">\n' +
                        '                <div class="service-desc">\n' +
                        '                    <h3>'+data[i].aname+'</h3>\n' +
                        '                    <p>'+data[i].aintroduce+'</p>\n' +
                        '                    <a class="easyui-linkbutton" data-options="iconCls:\'icon-add\'" onclick="dianwo('+data[i].aid+',${student.sid})">点击参加</a>\n' +
                        '                </div>\n' +
                        '            </div>';
                }

                $("#act").html(lis);
            });
        });
    </script>
</head>
<nav id="menu" class="navbar navbar-default navbar-fixed-top">
    <div class="container">

        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
            <a class="navbar-brand page-scroll" href="index.jsp">西安文理学院社团管理系统</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="index.jsp">首页</a></li>
                <li><a href="${pageContext.request.contextPath}/CommunityServlet?method=findCommunityCategory">社团</a></li>
                <li><a href="${pageContext.request.contextPath}/IndexServlet?method=findHonorWall">荣誉墙</a></li>
                <li><a href="${pageContext.request.contextPath}/IndexServlet?method=findHallOfFame">名人堂</a></li>
                <li><a href="${pageContext.request.contextPath}/Report.jsp">匿名投诉</a></li>
                <li><a href="${pageContext.request.contextPath}/loginForm.jsp">登录</a></li>
                <li><a href="${pageContext.request.contextPath}/StudentServlet?method=findFactoryId">注册</a></li>
                <c:if test="${ not empty student}">
                    <li><a href="${pageContext.request.contextPath}/person/personInfo.jsp">我的</a></li>
                </c:if>
            </ul>
        </div>
    </div>
</nav>
<!-- Header -->
<header id="header">
    <div class="intro">
        <div class="overlay">
            <div class="container">
                <div class="row">
                    <div class="col-md-8 col-md-offset-2 intro-text">
                        <h1>欢迎加入<br>
                            西安文理学院大学生社团</h1>
                        <p>大学社团是学生自愿组织的群众性团体，在校党委、团委的领导下，在学生社团联合会的指导下，组织开展健康、积极有益的课外文化、科技体育、艺术等活动，它组织开展我们同学们的各项活动，丰富了同学们的业余文化生活，培养学生的综合素质。它既不同于第一课堂的专业学习，又与自身的全面发展有着密切的联系。通过社团活动， 能拓展我们的视野，培养创新精神和实验能力，为我们实现自己的人生理想、从容的面对社会生活打下了坚实的基础.</p>
                </div>
            </div>
        </div>
    </div>
    </div>
</header>
<script>
    $(function(){
        $(".assocation-content").hide();
        //按钮点击事件
        $("button").click(function(){
            var txts = $(this).parents("li");
            if ($(this).text() == "展开"){
                $(this).text("收起");
                txts.find(".assocation-tit").hide();
                txts.find(".assocation-content").show();
            }else{
                $(this).text("展开");
                txts.find(".assocation-tit").show();
                txts.find(".assocation-content").hide();
            }
        })
    });
</script>
<div id="about">
    <div class="container">
        <div class="section-title">
            <h2>公告</h2>
        </div>
        <div class="row" id="notice">

        </div>
    </div>
</div>
<script>
    //需要参加活动的id
    function dianwo(aid,sid) {
        if (window.confirm('您确定要参加活动吗？')) {
            if(${empty student}){
                //没有登陆，跳转登陆页面
                window.location.href='loginForm.jsp';
                return false;
            }else{
            //发送报名给后台
            $.post("ActivityServlet",{method:'applyJoinActivity',aid:aid,sid:sid},function (data) {
                alert(data);
            });
            return true;
            }
        } else {
            alert("报名取消！");
            return false;
        }
    }
</script>
<div id="services">
    <div class="container">
        <div class="section-title">
            <h2>最新活动</h2>
        </div>
        <div class="row" id="act">

        </div>
    </div>
</div>
<div style="text-align: center;clear: both;">
    <br />
    Copyright © 雪绒花小组
</div>
</body>
</html>
